package org.bookie.model.services.impl;

import org.bookie.model.Period;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

public class HibernateDAO {
	/** The hibernate session */
	private Session session = null;

	public void setSession(Session session) {
		this.session = session;
	}

	public Session getSession() {
		return session;
	}

	protected void addPeriodCriteria(Criteria criteria, Period period) {
		if (null != period && period.isValid()) {
			if (null != period.getStart()) {
				criteria.add(Restrictions.ge("date", period.getStart()));
			}
			if (null != period.getEnd()) {
				criteria.add(Restrictions.le("date", period.getEnd()));
			}
		}
	}

}
